class Solution {
    public int reverse(int x) {
        if(x==0){
            return 0;
        }
        //判断符号
        int flag = 1;
        if (x<0) {
            flag = -1;
        }
        //取绝对值运算
        x = Math.abs(x);
        int res = 0;

        //正常取反
        while (x!=0){
            int temp = x%10+res*10;
            //当取反以后的值越界了，则返回0
            if((temp - x % 10)/10 !=res){
                return 0;
            }
            res = temp;
            x = x/10;
        }
        return res*flag;
    }
}

public class MainClass {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            int x = Integer.parseInt(line);
            
            int ret = new Solution().reverse(x);
            
            String out = String.valueOf(ret);
            
            System.out.print(out);
        }
    }
}